﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			BindGridView();
		}
	}

	private void BindGridView()
	{
		DataList1.DataSource = DbClass.GetDataTable(DbClass.GetSqlConnection(), "SELECT 产品ID,产品名称,单价,产品图片 FROM 产品 WHERE 产品名称 LIKE '%电视%'");
		DataList1.DataBind();
	}
	protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
	{

	}
	protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
	{
		ArrayList list;
		if (Session["buylist"] == null)
		{
			list = new ArrayList();
		}
		else
		{
			list = (ArrayList)Session["buylist"];
		}
		list.Add(e.CommandArgument);
		Session["buylist"] = list;
	}
	protected void Button1_Click(object sender, EventArgs e)
	{
		ArrayList list = (ArrayList)Session["buylist"];

		for(int i = 0; i < list.Count; i++)
		{
			Response.Write(list[i].ToString());
		}
	}
}
